#include <iostream>
#include <memory>
#include <vector>
using std::cout;
using std::endl;
using std::shared_ptr;
using std::vector;

class Point
{
public:
    Point(int x,int y)
    : _ix(x)
    , _iy(y)
    {}

    void print() const{
        cout << "(" << _ix
            << "," << _iy
            << ")" << endl;
    }
private:
    int _ix;
    int _iy;
};

void test1(){
    shared_ptr<Point> sp(new Point(1,2));  
    shared_ptr<Point> sp3(new Point(19,20));  
    vector<shared_ptr<Point>> vec;
    vec.push_back(sp);
    cout << sp.use_count() << endl;

    vec.push_back(std::move(sp3));
    cout << sp3.use_count() << endl;
    /* sp3->print(); */
}


void test0(){
    shared_ptr<Point> sp(new Point(1,2));  
    shared_ptr<Point> sp2(sp);
    (*sp).print();
    sp2->print();
    cout << sp.get() << endl;
    cout << sp2.get() << endl;
    cout << sp.use_count() << endl;
    cout << sp2.use_count() << endl;

    cout << endl;
    shared_ptr<Point> sp3(new Point(19,20));  
    sp = sp3;
    cout << sp.use_count() << endl;
    cout << sp2.use_count() << endl;
    cout << sp3.use_count() << endl;

    cout << endl;
    sp2 = sp3;
    cout << sp.use_count() << endl;
    cout << sp2.use_count() << endl;
    cout << sp3.use_count() << endl;
    sp->print();
}

int main(void){
    test1();
    return 0;
}
